package com.chance.cc.crawler.development.bootstrap.weibo;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

import java.util.Arrays;
import java.util.List;

/**
 * @Author Zhao.Hhuan
 * @Date Create in 2021/1/29 13:45
 * @Description 微博 api 临时采集入口
 **/
public class WeiboApiSimple {
    public static void main(String[] args) {
        List<String> strings = Arrays.asList(args);
        createRecord("weibo","apiSimpleHistory",
                "D:\\Download\\weibo_jsonData.txt",
                "D:\\Download\\weibo_post_likes.txt",
                false);
    }

    //site 必须是以apiSimple开头
    private static void createRecord(String domain,String site,String readFilePath,String writeFilePath,Boolean append){
        CrawlerRequestRecord build = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPageItem)
                .httpUrl("https://c.api.weibo.com/")
                .needWashed(false)
                .needParsed(false)
                .releaseTime(System.currentTimeMillis())
                .build();
        build.setDownload(false);
        build.setSkipPipeline(true);
        build.tagsCreator().bizTags().addSite("apiSimple");
        build.getHttpRequest().addExtra("1",readFilePath);
        build.getHttpRequest().addExtra("site",site);


        DevCrawlerController.builder()
                .triggerInfo(domain,domain,System.currentTimeMillis(),domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline()
                .fileResultPipeline(writeFilePath,append)
                .requestRecord(build)
                .build().start();
    }
}
